﻿

using GEMINI_OP90;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GEMINI_OP90
{
    public partial class FormManMode : Form
    {
        public FormManMode()
        {
            InitializeComponent();
        }
        //静音
        private void button2_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX0.2", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX0.2"));
        }
        //工位屏蔽
        private void button3_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX0.3", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX0.3"));
        }
        //RFID屏蔽
        private void button4_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX0.4", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX0.4"));
        }
        //相机屏蔽
        private void button5_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX0.5", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX0.5"));
        }
        //扫码屏蔽
        private void button6_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX0.6", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX0.6"));
        }
        //拧紧枪屏蔽1
        private void button7_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX0.7", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX0.7"));
        }
        //拧紧枪屏蔽2
        private void button8_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX1.0", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX1.0"));
        }
        //返回原位（大复位）
        private void button9_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX1.1", true);
        }
        private void button9_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX1.1", false);
        }
        //报警复位
        private void button10_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX1.2", true);
        }

        private void button10_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX1.2", false);
        }
        //防螺钉掉入屏蔽
        private void button11_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX2.5", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX2.5"));
        }
        //返修上线
        private void button12_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX1.4", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX1.4"));
        }
        //强制不合格
        private void button13_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX1.5", true);
        }

        private void button13_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX1.5", false);
        }
        //空托盘
        private void button14_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX1.6", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX1.6"));
        }
        //放行
        private void button15_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX1.7", true);
        }

        private void button15_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX1.7", false);

        }
        
        






        //状态
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX0.2"))
            {
                button2.BackColor = Color.Green;    //静音
            }
            else
            {
                button2.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX0.3"))
            {
                button3.BackColor = Color.Green;    //工位屏蔽
            }
            else
            {
                button3.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX0.4"))
            {
                button4.BackColor = Color.Green;    //RFID屏蔽
            }
            else
            {
                button4.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX0.5"))
            {
                button5.BackColor = Color.Green;    //相机屏蔽
            }
            else
            {
                button5.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX0.6"))
            {
                button6.BackColor = Color.Green;    //扫码屏蔽
            }
            else
            {
                button6.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX0.7"))
            {
                button7.BackColor = Color.Green;    //拧紧枪屏蔽1
            }
            else
            {
                button7.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX1.0"))
            {
                button8.BackColor = Color.Green;    //拧紧枪屏蔽2
            }
            else
            {
                button8.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX1.1"))
            {
                button9.BackColor = Color.Green;    //返回原位
            }
            else
            {
                button9.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX1.2"))
            {
                button10.BackColor = Color.Green;   //复位
            }
            else
            {
                button10.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX2.5"))
            {
                button11.BackColor = Color.Green;   //防螺钉掉入屏蔽
            }
            else
            {
                button11.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX1.4"))
            {
                button12.BackColor = Color.Green;   //返修件
            }
            else
            {
                button12.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX1.5"))
            {
                button13.BackColor = Color.Green;   //强制不合格
            }
            else
            {
                button13.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX1.6"))
            {
                button14.BackColor = Color.Green;   //空托盘
            }
            else
            {
                button14.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX1.7"))
            {
                button15.BackColor = Color.Green;   //放行
            }
            else
            {
                button15.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX28.0"))
            {
                button1.BackColor = Color.Green;    //顶升伸出
            }
            else
            {
                button1.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX28.1"))
            {
                button16.BackColor = Color.Green;   //顶升缩回
            }
            else
            {
                button16.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX2.0"))
            {
                button18.BackColor = Color.Green;   //前挡停
            }
            else
            {
                button18.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX2.1"))
            {
                button20.BackColor = Color.Green;   //后挡停
            }
            else
            {
                button20.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX96.0"))
            {
                button19.BackColor = Color.Green;   //膨胀阀
            }
            else
            {
                button19.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX1.3"))
            {
                button17.BackColor = Color.Green;   //测试上线
            }
            else
            {
                button17.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX96.1"))
            {
                button21.BackColor = Color.Green;   //暖芯手动正压测试
            }
            else
            {
                button21.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX96.2"))
            {
                button22.BackColor = Color.Green;   //暖芯手动负压测试
            }
            else
            {
                button22.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX100.3"))
            {
                button23.BackColor = Color.Green;   //蒸发器手动负压测试
            }
            else
            {
                button23.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX100.0"))
            {
                button26.BackColor = Color.Green;   //正压程序号写入
            }
            else
            {
                button26.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX100.1"))
            {
                button27.BackColor = Color.Green;   //负压程序号写入
            }
            else
            {
                button27.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX97.0"))
            {
                button28.BackColor = Color.Green;   //手动切换
            }
            else
            {
                button28.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX96.7"))
            {
                button25.BackColor = Color.Green;   //手动打开真空泵
            }
            else
            {
                button25.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX30.0"))
            {
                button24.BackColor = Color.Green;   //推进气缸伸出
            }
            else
            {
                button24.BackColor = Color.Silver;
            }
            if (FormMain.PLC_Link[0].readBoolen("DB7050.DBX30.1"))
            {
                button29.BackColor = Color.Green;   //推进气缸缩回
            }
            else
            {
                button29.BackColor = Color.Silver;
            }

        }
        //顶升气缸伸出
        private void button1_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX4.0", true);
        }

        private void button1_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX4.0", false);
        }
        //顶升气缸缩回
        private void button16_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX4.1", true);
        }

        private void button16_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX4.1", false);
        }
        //测试上线
        private void button17_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX1.3", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX1.3"));
        }
        //OP70前挡停打开
        private void button18_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX2.0", true);
        }

        private void button18_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX2.0", false);
        }
        //OP70后挡停打开
        private void button20_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX2.1", true);
        }

        private void button20_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX2.1", false);
        }
        //膨胀阀
        private void button19_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX96.0", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX96.0"));
        }
        //暖芯手动正压测试
        private void button21_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX96.1", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX96.1"));
        }
        //暖芯手动负压测试
        private void button22_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX96.2", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX96.2"));
        }
        //蒸发器手动负压测试
        private void button23_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX100.3", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX100.3"));
        }
        //手动打开真空泵
        private void button25_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX96.7", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX96.7"));
        }
        //手动切换
        private void button28_Click(object sender, EventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX97.0", !FormMain.PLC_Link[0].readBoolen("DB7050.DBX97.0"));
        }
        //正压程序号写入
        private void button26_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX100.0", true);
        }

        private void button26_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX100.0", false);
        }
        //负压程序号写入
        private void button27_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX100.1", true);
        }

        private void button27_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX100.1", false);
        }
        //推进气缸伸出
        private void button24_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX6.0", true);
        }

        private void button24_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX6.0", false);
        }
        //推进气缸缩回
        private void button29_MouseDown(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX6.1", true);
        }

        private void button29_MouseUp(object sender, MouseEventArgs e)
        {
            FormMain.PLC_Link[0].WriteBoolen("DB7050.DBX6.1", false);
        }
        //配置NG自动放行时间给PLC    //待验证
        private void button30_Click(object sender, EventArgs e)
        {
            int i = Convert.ToInt32(textBox6.Text) * 1000;
            FormMain.PLC_Link[0].WriteInt("DB7050.DBD108", i);
        }
    }
}
